package com.anlogic.sdk.ui.handlers;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;

import com.anlogic.sdk.utils.EnvUtils;
import com.anlogic.sdk.utils.FileUtils;
import com.anlogic.sdk.utils.UIUtils;

public class ReleaseNotes extends AbstractHandler {
	public Object execute(final ExecutionEvent event) throws ExecutionException {
		String doc = EnvUtils.getIDERootPath() + "/doc/FD_Release_Notes.pdf";
		Desktop desktop = Desktop.getDesktop();
		if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {
			try {
				URI uri = FileUtils.filePathToURI(doc);
				desktop.browse(uri);
			} catch (IOException e) {
				UIUtils.showMessageDialog("Open Document", "Can not open document!", MessageDialog.ERROR);
			}
		}
		return null;
	}
}
